﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>Update</title>
    <script src='@Url.Content("~/Scripts/zTree/js/jquery-1.4.4.min.js")' type="text/javascript"></script>
    <link href='@Url.Content("~/Scripts/zTree/css/zTreeStyle/zTreeStyle.css")' rel="stylesheet" type="text/css" />
    <script src='@Url.Content("~/Scripts/zTree/js/jquery.ztree.core-3.5.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Scripts/zTree/js/jquery.ztree.excheck-3.5.js")' type="text/javascript"></script>
    <script src='@Url.Content("~/Scripts/zTree/js/jquery.ztree.exedit-3.5.js")' type="text/javascript"></script>
    <script src="../../Scripts/PageCreater/Scripts/PageCreater.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $.ajaxSetup({ cache: false });
            $.get("/StrategyExma/GetCourseNameByTask", { id: getUrlPara() }, function (data) {
                $("#spCourseName").append(data);
            });
            $.fn.zTree.init($("#treeType"), typeSetting, zNodesType);
            $.fn.zTree.init($("#treeKnow"), knowSetting, zNodesKnow);
            $.fn.zTree.init($("#treeDiff"), setting, zNodesDiff);
            $.fn.zTree.init($("#treeStrategy"), strategySetting, zNodesStrategy);
            var a = $("#PersId").val(); ;
            if (a == 'True') {
                $("#exam").attr({ checked: "checked" });
            }
        })
        var typeSetting = {
            async: {
                enable: true,
                url: "/StrategyExma/GetAllType",
                type: "Get",
                dataType: "json"
            },
            edit: {
                enable: false,
                showRemoveBtn: false,
                showRenameBtn: false,
                drag: {
                    isCopy: true,
                    isMove: false,
                    prev: false,
                    inner: false,
                    next: false
                }
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            },
            callback: {
                onAsyncSuccess: function (event, treeId, treeNode, msg) {
                },
                onAsyncError: function (event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
                },
                beforeDrag: beforeDrag,
                beforeDrop: beforeDrop
            }
        };
        var knowSetting = {
            async: {
                enable: true,
                url: "/StrategyExma/GetAllKnowledgePoint",
                type: "Get",
                dataType: "json",
                otherParam: { courseID: getUrlPara() }
            },
            edit: {
                enable: true,
                showRemoveBtn: false,
                showRenameBtn: false,
                drag: {
                    isCopy: true,
                    isMove: false,
                    prev: false,
                    inner: false,
                    next: false
                }
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            },
            callback: {
                onAsyncSuccess: function (event, treeId, treeNode, msg) {
                },
                onAsyncError: function (event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
                },
                beforeDrag: beforeDrag,
                beforeDrop: beforeDrop
            }
        };
        var setting = {
            edit: {
                enable: true,
                showRemoveBtn: false,
                showRenameBtn: false,
                drag: {
                    isCopy: true,
                    isMove: false,
                    prev: false,
                    inner: false,
                    next: false
                }
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                beforeDrag: beforeDrag,
                beforeDrop: beforeDrop
            }
        };
        var strategySetting = {
            async: {
                enable: true,
                url: "/StrategyExma/GetStrategyedByID",
                type: "Get",
                dataType: "json",
                otherParam: { taskId: getUrlPara() }
            },
            edit: {
                enable: true,
                showRemoveBtn: true,
                showRenameBtn: false
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            view: {
                addDiyDom: addDiyDom
            },
            callback: {
                onAsyncSuccess: function (event, treeId, treeNode, msg) {
                }
              
            }
        };
        var zNodesType = [
            { id: 0, pid: -1, name: "请选择题型", isParent: true, drag: false }
		];
        var zNodesKnow = [
			{ id: 0, pid: -1, name: "请选择知识点", isParent: true, drag: false }
		];
        var zNodesDiff = [
            { id: 0, pId: -1, name: "请选难度", isParent: true, drag: false },
			{ id: 1, pId: 0, name: "简单", tld: "diff1" },
			{ id: 2, pId: 0, name: "一般", tld: "diff2" },
			{ id: 3, pId: 0, name: "难", tld: "diff3" },
			{ id: 4, pId: 0, name: "较难", tld: "diff4" }
		];
        var zNodesStrategy = [
		];
        function addDiyDom(treeId, treeNode) {
            var val = "";
            if (treeNode.weight != undefined) {
                val = treeNode.weight;
            }
            var treeObj = $.fn.zTree.getZTreeObj(treeId);
            var aObj = $("#" + treeNode.tId + "_a");
            if ($.browser.msie) {
                var node, parNode;
                node = treeObj.getNodeByTId(treeNode.parentTId);
                if (node != null) {
                    parNode = treeObj.getNodeByTId(node.parentTId);
                }
                if (parNode != null) {
                    if (treeNode.level == 2) {
                        var editStr = "<div style=' float:right;'><span>题量：</span>" + "<span  id='" + parNode.tld + "_" + node.tld + "_" + treeNode.tld + "" + "_Num' type='text'>" + treeNode.num + "</span>&nbsp;&nbsp;&nbsp;<span>权重：</span>" + "<span id='" + parNode.tld + "_" + node.tld + "_" + treeNode.tld + "" + "' type='text' >" + val + "</span></div>";
                    } else {
                        var editStr = "<div style=' float:right;'><span>权重：</span>" + "<span  id='" + parNode.tld + "_" + node.tld + "_" + treeNode.tld + "" + "' type='text' value='" + val + "' /></div>";
                    }
                } else {
                    if (node != null) {
                        if (treeNode.level == 2) {
                            var editStr = "<div style=' float:right;'><span>题量：</span>" + "<span  id='" + node.tld + "_" + treeNode.tld + "" + "_Num' type='text'>" + treeNode.num + "</span>&nbsp;&nbsp;&nbsp;<span>权重：</span>" + "<span id='" + node.tld + "_" + treeNode.tld + "" + "' type='text' >" + val + "</span></div>";
                        } else {
                            var editStr = "<div style=' float:right;'><span>权重：</span>" + "<span id='" + node.tld + "_" + treeNode.tld + "" + "' type='text'>" + val + "</span></div>";
                        }
                    } else {
                        if (treeNode.level == 2) {
                            var editStr = "<div style=' float:right;'><span>题量：</span>" + "<span  id='" + treeNode.tld + "" + "_Num' type='text'>" + treeNode.num + "</span>&nbsp;&nbsp;&nbsp;<span>权重：</span>" + "<span id='" + treeNode.tld + "" + "' type='text'  >" + val + "</span></div>";
                        } else {
                            var editStr = "<div style=' float:right;'><span>权重：</span>" + "<span  id='" + treeNode.tld + "" + "' type='text'>" + val + "</span></div>";
                        }
                    }
                }
            } else {
                var node, parNode;
                node = treeObj.getNodeByTId(treeNode.parentTId);
                if (node != null) {
                    parNode = treeObj.getNodeByTId(node.parentTId);
                }
                if (parNode != null) {
                    if (treeNode.level == 2) {
                        var editStr = "<div style=' float:right;'><span>题量：</span>" + "<span  id='" + parNode.tld + "_" + node.tld + "_" + treeNode.tld + "" + "_Num' type='text'>" + treeNode.num + "</span>&nbsp;&nbsp;&nbsp;<span>权重：</span>" + "<span id='" + parNode.tld + "_" + node.tld + "_" + treeNode.tld + "" + "' type='text' >" + val + "</span></div>";
                    } else {
                        var editStr = "<div style=' float:right;'><span>权重：</span>" + "<span  id='" + parNode.tld + "_" + node.tld + "_" + treeNode.tld + "" + "' type='text' value='" + val + "' /></div>";
                    }
                } else {
                    if (node != null) {
                        if (treeNode.level == 2) {
                            var editStr = "<div style=' float:right;'><span>题量：</span>" + "<span  id='" + node.tld + "_" + treeNode.tld + "" + "_Num' type='text'>" + treeNode.num + "</span>&nbsp;&nbsp;&nbsp;<span>权重：</span>" + "<span id='" + node.tld + "_" + treeNode.tld + "" + "' type='text' >" + val + "</span></div>";
                        } else {
                            var editStr = "<div style=' float:right;'><span>权重：</span>" + "<span id='" + node.tld + "_" + treeNode.tld + "" + "' type='text'>" + val + "</span></div>";
                        }
                    } else {
                        if (treeNode.level == 2) {
                            var editStr = "<div style=' float:right;'><span>题量：</span>" + "<span  id='" + treeNode.tld + "" + "_Num' type='text'>" + treeNode.num + "</span>&nbsp;&nbsp;&nbsp;<span>权重：</span>" + "<span id='" + treeNode.tld + "" + "' type='text'  >" + val + "</span></div>";
                        } else {
                            var editStr = "<div style=' float:right;'><span>权重：</span>" + "<span  id='" + treeNode.tld + "" + "' type='text'>" + val + "</span></div>";
                        }
                    }
                }
            }
            aObj.after(editStr);
        }
        function beforeDrag(treeId, treeNodes) {
            for (var i = 0, l = treeNodes.length; i < l; i++) {
                if (treeNodes[i].drag === false) {
                    return false;
                }
            }
            return true;
        }
        function beforeDrop(treeId, treeNodes, targetNode, moveType) {
            return targetNode ? targetNode.drop !== false : true;
        }

        function SubmitPage() {
            var item = $(":input:checked");
            var len = item.length;
            if (len > 0) {
                $("#exams").val("true");
            }
            else {

                $("#exams").val("false");
            }
            var ispass = $("#exams").val();
            var auditOpinion = $("#suggestion").val();
            var ID = $("#sId").val();
            $.post("/StrategyExma/Update", { ID: ID, Ispass: ispass, AuditOpinion: auditOpinion, score: function () { return $("#txtScore").val(); }}, function () {
                alert("提交成功！");
            });
        }
    </script>
</head>
<body>
    @Html.ActionLink("返回列表", "Index")
    <div style="margin-top: 10px; margin-left: 10px;">
        <span>你当前选择的课程：</span><span style="color: Red" id="spCourseName"></span><br />
        <br />
        <span>分值为：</span><input id="txtScore" type="text" value='@TempData["Score"]' /><br />
        <br />
          <span>考试时间：</span><span id="txtMin" type="text">@TempData["Min"]</span><br />
          <input type="checkbox"  id="exam" checked="checked"  /> 是否通过审核
        <div>
            <fieldset style="float: left; width: 40%; height: 300px;">
                <legend>出题策略</legend>
                <div id="divResult">
                    <ul id="treeStrategy" style="height: 275px; width: 98%" class="ztree">
                    </ul>
                </div>
            </fieldset>
            <fieldset style="float: left; width: 300px; height: 300px; overflow-y: scroll;border:0;">
                <legend>审核意见</legend>
               <textarea style="height: 275px; width: 98%;overflow-x:hidden;overflow-y:hidden;"" id="suggestion" rows="2" cols="1" >@TempData["auditOpinion"]</textarea>
            </fieldset>
            <div style="clear: both; padding-top: 20px;">
             <input  type="hidden" value=""  id="exams"/>
             <input  type="hidden" value="@TempData["ID"]"  id="sId"/>
             <input type="hidden" id="PersId" value="@TempData["Isactive"]" />
                <input type="button" value="提交" onclick="SubmitPage()" style="width: auto" />
            </div>
        </div>
    </div>
</body>
</html>
